{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.7.3 64-bit ('ml2': pyenv)"
  },
  "interpreter": {
   "hash": "8caa4319d59a734f94e739df6b594acde678ec5f2e3eb7152d087fc4a1992669"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "from ml2.ltl import LTLSpec\n",
    "from ml2.tools.nuxmv import nuXmv"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "source": [
    "nuxmv = nuXmv()"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stderr",
     "text": [
      "INFO:ml2.tools.containerized_grpc_service:Pulling Docker image ghcr.io/reactive-systems/ml2/nuxmv-grpc-server:latest\n",
      "INFO:ml2.tools.containerized_grpc_service:nuXmv container modest_tharp on port 50051 is running\n",
      "INFO:ml2.tools.containerized_grpc_service:Successfully connected to nuXmv gRPC server running in container modest_tharp on port 50051\n"
     ]
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "source": [
    "spec_dict = {\n",
    "    \"guarantees\": [\n",
    "        \"G ( i0 -> ( F o0 ) )\",\n",
    "        \"G ( i1 -> ( F o1 ) )\",\n",
    "        \"G ! (o0 & o1)\"\n",
    "      ],\n",
    "      \"inputs\": [\n",
    "        \"i0\",\n",
    "        \"i1\",\n",
    "        \"i2\",\n",
    "        \"i3\",\n",
    "        \"i4\"\n",
    "      ],\n",
    "      \"outputs\": [\n",
    "        \"o0\",\n",
    "        \"o1\",\n",
    "        \"o2\",\n",
    "        \"o3\",\n",
    "        \"o4\"\n",
    "      ],\n",
    "}"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "source": [
    "spec = LTLSpec.from_dict(spec_dict)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "source": [
    "circuit = 'aag 6 5 1 5 0\\n2\\n4\\n6\\n8\\n10\\n12 13\\n13\\n12\\n0\\n0\\n0\\ni0 i0\\ni1 i1\\ni2 i2\\ni3 i3\\ni4 i4\\nl0 l0\\no0 o0\\no1 o1\\no2 o2\\no3 o3\\no4 o4\\n'"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "source": [
    "nuxmv.model_check(spec, circuit, realizable=True)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<LTLMCStatus.SATISFIED: 'satisfied'>"
      ]
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "source": [
    "del nuxmv"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stderr",
     "text": [
      "INFO:ml2.tools.containerized_grpc_service:Stopped and removed container modest_tharp running nuXmv on port 50051\n"
     ]
    }
   ],
   "metadata": {}
  }
 ]
}